﻿namespace WMS6.Web
{
    using System;
    using System.Collections.Generic;
    using System.Data;
    using WMS6.Web.CustomsServiceRef;

    public class CustomsServiceClientProxy : BasePage
    {
        public string DeleteDeclarationsInfo(List<string> DeclarationsID)
        {
            PubParasInfo pubParasInfo = this.InitPubParasInfo();
            string result = string.Empty;
            CustomsServiceClient client = new CustomsServiceClient("WSHttpBinding_ICustomsService");
            try
            {
                result = client.DeleteDeclarationsInfo(DeclarationsID, pubParasInfo);
                client.Close();
            }
            catch (Exception ex)
            {
                client.Abort();
                SysLog.GetInstance().LogProxyError(ex);
            }
            return result;
        }

        public string DeleteEXDeclarationsInfo(List<string> DeclarationsID)
        {
            PubParasInfo pubParasInfo = this.InitPubParasInfo();
            string result = string.Empty;
            CustomsServiceClient client = new CustomsServiceClient("WSHttpBinding_ICustomsService");
            try
            {
                result = client.DeleteEXDeclarationsInfo(DeclarationsID, pubParasInfo);
                client.Close();
            }
            catch (Exception ex)
            {
                client.Abort();
                SysLog.GetInstance().LogProxyError(ex);
            }
            return result;
        }

        public DataSet GetDeclarationsBlanaceRptDataSet(DeclarationsBlanaceRptQueryEntity declarationsBlanaceRptQueryEntity)
        {
            PubParasInfo pubParasInfo = this.InitPubParasInfo();
            DataSet ds = null;
            CustomsServiceClient client = new CustomsServiceClient("WSHttpBinding_ICustomsService");
            try
            {
                ds = client.GetDeclarationsBlanaceRptDataSet(declarationsBlanaceRptQueryEntity, pubParasInfo);
                client.Close();
            }
            catch (Exception ex)
            {
                client.Abort();
                SysLog.GetInstance().LogProxyError(ex);
            }
            return ds;
        }

        public ImportDeclarationsInfo GetDeclarationsInfoByID(string id)
        {
            PubParasInfo pubParasInfo = this.InitPubParasInfo();
            ImportDeclarationsInfo importDeclarationsInfo = null;
            CustomsServiceClient client = new CustomsServiceClient("WSHttpBinding_ICustomsService");
            try
            {
                importDeclarationsInfo = client.GetDeclarationsInfoByID(id, pubParasInfo);
                client.Close();
            }
            catch (Exception ex)
            {
                client.Abort();
                SysLog.GetInstance().LogProxyError(ex);
            }
            return importDeclarationsInfo;
        }

        public DataSet GetDeclarationsInfoByQueryEntity(ImportDeclarationsQueryEntity importDeclarationsQueryEntity)
        {
            PubParasInfo pubParasInfo = this.InitPubParasInfo();
            DataSet ds = null;
            CustomsServiceClient client = new CustomsServiceClient("WSHttpBinding_ICustomsService");
            try
            {
                ds = client.GetDeclarationsInfoByQueryEntity(importDeclarationsQueryEntity, pubParasInfo);
                client.Close();
            }
            catch (Exception ex)
            {
                client.Abort();
                SysLog.GetInstance().LogProxyError(ex);
            }
            return ds;
        }

        public DataSet GetDeclarationsInOutDetailRptDataSet(DeclarationsInOutDetailRptQueryEntity declarationsInOutDetailRptQueryEntity)
        {
            PubParasInfo pubParasInfo = this.InitPubParasInfo();
            DataSet ds = null;
            CustomsServiceClient client = new CustomsServiceClient("WSHttpBinding_ICustomsService");
            try
            {
                ds = client.GetDeclarationsInOutDetailRptDataSet(declarationsInOutDetailRptQueryEntity, pubParasInfo);
                client.Close();
            }
            catch (Exception ex)
            {
                client.Abort();
                SysLog.GetInstance().LogProxyError(ex);
            }
            return ds;
        }

        public DataSet GetDeclarationsItemNoBlanaceRptDataSet(DeclarationsItemNoBlanaceRptQueryEntity declarationsItemNoBlanaceRptQueryEntity)
        {
            PubParasInfo pubParasInfo = this.InitPubParasInfo();
            DataSet ds = null;
            CustomsServiceClient client = new CustomsServiceClient("WSHttpBinding_ICustomsService");
            try
            {
                ds = client.GetDeclarationsItemNoBlanaceRptDataSet(declarationsItemNoBlanaceRptQueryEntity, pubParasInfo);
                client.Close();
            }
            catch (Exception ex)
            {
                client.Abort();
                SysLog.GetInstance().LogProxyError(ex);
            }
            return ds;
        }

        public ExportDeclarationsInfo GetEXDeclarationsInfoByID(string id)
        {
            PubParasInfo pubParasInfo = this.InitPubParasInfo();
            ExportDeclarationsInfo exportDeclarationsInfo = null;
            CustomsServiceClient client = new CustomsServiceClient("WSHttpBinding_ICustomsService");
            try
            {
                exportDeclarationsInfo = client.GetEXDeclarationsInfoByID(id, pubParasInfo);
                client.Close();
            }
            catch (Exception ex)
            {
                client.Abort();
                SysLog.GetInstance().LogProxyError(ex);
            }
            return exportDeclarationsInfo;
        }

        public DataSet GetEXDeclarationsInfoByQueryEntity(ExportDeclarationsQueryEntity exportDeclarationsQueryEntity)
        {
            PubParasInfo pubParasInfo = this.InitPubParasInfo();
            DataSet ds = null;
            CustomsServiceClient client = new CustomsServiceClient("WSHttpBinding_ICustomsService");
            try
            {
                ds = client.GetEXDeclarationsInfoByQueryEntity(exportDeclarationsQueryEntity, pubParasInfo);
                client.Close();
            }
            catch (Exception ex)
            {
                client.Abort();
                SysLog.GetInstance().LogProxyError(ex);
            }
            return ds;
        }

        public DataSet GetExportDeclarationsRptDateSet(ExportDeclarationsRptQueryEntity exportDeclarationsRptQueryEntity)
        {
            PubParasInfo pubParasInfo = this.InitPubParasInfo();
            DataSet ds = null;
            CustomsServiceClient client = new CustomsServiceClient("WSHttpBinding_ICustomsService");
            try
            {
                ds = client.GetExportDeclarationsRptDateSet(exportDeclarationsRptQueryEntity, pubParasInfo);
                client.Close();
            }
            catch (Exception ex)
            {
                client.Abort();
                SysLog.GetInstance().LogProxyError(ex);
            }
            return ds;
        }

        public DataSet GetImportDeclarationsRptDateSet(ImportDeclarationsRptQueryEntity importDeclarationsRptQueryEntity)
        {
            PubParasInfo pubParasInfo = this.InitPubParasInfo();
            DataSet ds = null;
            CustomsServiceClient client = new CustomsServiceClient("WSHttpBinding_ICustomsService");
            try
            {
                ds = client.GetImportDeclarationsRptDateSet(importDeclarationsRptQueryEntity, pubParasInfo);
                client.Close();
            }
            catch (Exception ex)
            {
                client.Abort();
                SysLog.GetInstance().LogProxyError(ex);
            }
            return ds;
        }

        public static CustomsServiceClientProxy GetInstance()
        {
            return new CustomsServiceClientProxy();
        }

        private PubParasInfo InitPubParasInfo()
        {
            return new PubParasInfo { UserID = base.UserInfo.UserID, UserLanguage = base.UserInfo.Preference.Lang, CurrentWH = base.UserInfo.CurrentWH };
        }

        public string InsertDeclarationsInfo(ImportDeclarationsInfo importDeclarationsInfo)
        {
            PubParasInfo pubParasInfo = this.InitPubParasInfo();
            string result = string.Empty;
            CustomsServiceClient client = new CustomsServiceClient("WSHttpBinding_ICustomsService");
            try
            {
                result = client.InsertDeclarationsInfo(importDeclarationsInfo, pubParasInfo);
                client.Close();
            }
            catch (Exception ex)
            {
                client.Abort();
                SysLog.GetInstance().LogProxyError(ex);
            }
            return result;
        }

        public string InsertEXDeclarationsInfo(ExportDeclarationsInfo exportDeclarationsInfo)
        {
            PubParasInfo pubParasInfo = this.InitPubParasInfo();
            string result = string.Empty;
            CustomsServiceClient client = new CustomsServiceClient("WSHttpBinding_ICustomsService");
            try
            {
                result = client.InsertEXDeclarationsInfo(exportDeclarationsInfo, pubParasInfo);
                client.Close();
            }
            catch (Exception ex)
            {
                client.Abort();
                SysLog.GetInstance().LogProxyError(ex);
            }
            return result;
        }

        public ExportDeclarationsInfo OrderIDChanged(string orderID, string type, string ownerID)
        {
            PubParasInfo pubParasInfo = this.InitPubParasInfo();
            ExportDeclarationsInfo exportDeclarationsInfo = null;
            CustomsServiceClient client = new CustomsServiceClient("WSHttpBinding_ICustomsService");
            try
            {
                exportDeclarationsInfo = client.OrderIDChanged(orderID, type, ownerID, pubParasInfo);
                client.Close();
            }
            catch (Exception ex)
            {
                client.Abort();
                SysLog.GetInstance().LogProxyError(ex);
            }
            return exportDeclarationsInfo;
        }

        public ImportDeclarationsInfo ReceiptIDChanged(string recepitID, string type, string ownerID)
        {
            PubParasInfo pubParasInfo = this.InitPubParasInfo();
            ImportDeclarationsInfo importDeclarationsInfo = null;
            CustomsServiceClient client = new CustomsServiceClient("WSHttpBinding_ICustomsService");
            try
            {
                importDeclarationsInfo = client.ReceiptIDChanged(recepitID, type, ownerID, pubParasInfo);
                client.Close();
            }
            catch (Exception ex)
            {
                client.Abort();
                SysLog.GetInstance().LogProxyError(ex);
            }
            return importDeclarationsInfo;
        }

        public string UpdateDeclarationsInfo(ImportDeclarationsInfo importDeclarationsInfo)
        {
            PubParasInfo pubParasInfo = this.InitPubParasInfo();
            string result = string.Empty;
            CustomsServiceClient client = new CustomsServiceClient("WSHttpBinding_ICustomsService");
            try
            {
                result = client.UpdateDeclarationsInfo(importDeclarationsInfo, pubParasInfo);
                client.Close();
            }
            catch (Exception ex)
            {
                client.Abort();
                SysLog.GetInstance().LogProxyError(ex);
            }
            return result;
        }

        public string UpdateDeclarationsInfoData(ImportDeclarationsInfo importDeclarationsInfo)
        {
            PubParasInfo pubParasInfo = this.InitPubParasInfo();
            string result = string.Empty;
            CustomsServiceClient client = new CustomsServiceClient("WSHttpBinding_ICustomsService");
            try
            {
                result = client.UpdateDeclarationsInfoData(importDeclarationsInfo, pubParasInfo);
                client.Close();
            }
            catch (Exception ex)
            {
                client.Abort();
                SysLog.GetInstance().LogProxyError(ex);
            }
            return result;
        }

        public string UpdateDeclarationsStatus(string declarationsID, string status, string verificationFormID)
        {
            PubParasInfo pubParasInfo = this.InitPubParasInfo();
            string result = string.Empty;
            CustomsServiceClient client = new CustomsServiceClient("WSHttpBinding_ICustomsService");
            try
            {
                result = client.UpdateDeclarationsStatus(declarationsID, status, verificationFormID, pubParasInfo);
                client.Close();
            }
            catch (Exception ex)
            {
                client.Abort();
                SysLog.GetInstance().LogProxyError(ex);
            }
            return result;
        }

        public string UpdateEXDeclarationsInfo(ExportDeclarationsInfo exportDeclarationsInfo)
        {
            PubParasInfo pubParasInfo = this.InitPubParasInfo();
            string result = string.Empty;
            CustomsServiceClient client = new CustomsServiceClient("WSHttpBinding_ICustomsService");
            try
            {
                result = client.UpdateEXDeclarationsInfo(exportDeclarationsInfo, pubParasInfo);
                client.Close();
            }
            catch (Exception ex)
            {
                client.Abort();
                SysLog.GetInstance().LogProxyError(ex);
            }
            return result;
        }

        public string UpdateEXDeclarationsInfoData(ExportDeclarationsInfo exportDeclarationsInfo)
        {
            PubParasInfo pubParasInfo = this.InitPubParasInfo();
            string result = string.Empty;
            CustomsServiceClient client = new CustomsServiceClient("WSHttpBinding_ICustomsService");
            try
            {
                result = client.UpdateEXDeclarationsInfoData(exportDeclarationsInfo, pubParasInfo);
                client.Close();
            }
            catch (Exception ex)
            {
                client.Abort();
                SysLog.GetInstance().LogProxyError(ex);
            }
            return result;
        }

        public string UpdateEXDeclarationsStatus(string declarationsID, string status, string verificationFormID)
        {
            PubParasInfo pubParasInfo = this.InitPubParasInfo();
            string result = string.Empty;
            CustomsServiceClient client = new CustomsServiceClient("WSHttpBinding_ICustomsService");
            try
            {
                result = client.UpdateEXDeclarationsStatus(declarationsID, status, verificationFormID, pubParasInfo);
                client.Close();
            }
            catch (Exception ex)
            {
                client.Abort();
                SysLog.GetInstance().LogProxyError(ex);
            }
            return result;
        }
    }
}

